'''
    events.py
    This file is part of:
    ActionCal - A Simple Calendar

    Copyright (C) 2006, 2007  R. P. Dillon

    This program is free software; you can redistribute it and/or modify
    it under the terms of version 2 the GNU General Public License as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'''

######################################################################
# Event Structure
######################################################################
class eventmanager(object):
    """
    A master event handler that can notify various elements of the
    application when certain conditions occur.
    """

    listeners = []

    def register(self, listener):
        """
        Add the specified listener to this manager.

        A listener cannot be registered twice: if it is attempted,
        attempts after the first will be ignored.
        """
        if (listener != None) and (not (listener in self.listeners)):
            self.listeners.append(listener)

    def post (self, event):
        """
        Posts an event to the registered listeners.
        """

        for listener in self.listeners:
            listener.handle(event)

# A series of events used for inter-component communication
class event(object):
    pass

class setdaytextevent(event):
    def __init__(self, date, text):
        self.date = date
        self.text = text

class requestmonthdataevent(event):
    def __init__(self, month):
        self.month = month

class monthdataevent(event):
    def __init__(self, month, data):
        self.month = month
        self.data = data

class KeyBindEvent(event):
    def __init__(self, key, function):
        self.key = key
        self.function = function

class setactivedateevent(event):
    def __init__(self, date):
        self.date = date

class persistdataevent(event):
    pass

class SyncEvent(event):
    pass

class startedittingevent(event):
    pass

class stopedittingevent(event):
    pass
